//
//  MLZLZCommunityTableViewCell.m
//  MotherLover
//
//  Created by lanou on 16/1/10.
//  Copyright © 2016年 zj. All rights reserved.
//

#import "MLZLZCommunityTableViewCell.h"

@implementation MLZLZCommunityTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
    //头像
        _buttonIco = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _buttonIco.frame = CGRectMake(CLandR, CTandB, (KW-CLandR*2)/5,(KW-CLandR*2)/5);
        _buttonIco.backgroundColor = [UIColor blackColor];
        [_buttonIco.layer setCornerRadius:(KW-CLandR*2)/5/2];
        _buttonIco.layer.masksToBounds= YES;
        [self.contentView addSubview:_buttonIco];
    //名字
        _lableName = [[UILabel alloc]initWithFrame:CGRectMake(_buttonIco.right+CM, _buttonIco.frame.origin.y, _buttonIco.width*2, _buttonIco.height/2)];
        //_lableName.backgroundColor = [UIColor blackColor];
        _lableName.textColor= [UIColor redColor];
        [self.contentView addSubview:_lableName];
        //时间
        _lableTime = [[UILabel alloc]initWithFrame:CGRectMake(_buttonIco.right+CM, _lableName.bottom+CM, _buttonIco.width*2, _buttonIco.height/2)];
        //_lableTime.backgroundColor = [UIColor blackColor];
        _lableTime.textColor= [UIColor grayColor];
        _lableTime.font= [UIFont systemFontOfSize:8];
        [self.contentView addSubview:_lableTime];
      //楼层
        
        _labletype = [[UILabel alloc]initWithFrame:CGRectMake(KW-CLandR-70, _lableName.bottom+CM, 70, _buttonIco.height/2)];
        //_labletype.backgroundColor = [UIColor blackColor];
        _labletype.textColor= [UIColor grayColor];
        [self.contentView addSubview:_labletype];
     //内容
        _lableContents = [[UILabel alloc]initWithFrame:CGRectMake(CLandR, _lableTime.bottom+CTandB, KW- CLandR*2 , 100)];
        _lableContents.numberOfLines= -1;
       // _lableContents.backgroundColor = [UIColor blackColor];
        //_lableContents.textColor= [UIColor grayColor];
        [self.contentView addSubview:_lableContents];

    
    }




    return self;




}
-(void)setModel:(MLZPostsModel *)model{

    _lableName.text  = model.userName;
    _lableTime.text = model.updatedAt;
    _labletype.text = @"楼主";
    _lableContents.text= model.contents;
    [_lableContents sizeToFit];
    if(model.picture.length==2){
        [_buttonIco setBackgroundImage:[UIImage imageNamed:@"xiaotou"] forState:(UIControlStateNormal )];
    }else{
         [_buttonIco sd_setBackgroundImageWithURL:[NSURL URLWithString:model.picture] forState:(UIControlStateNormal)];
    }

   
    if([_delegate respondsToSelector:@selector(FHfloatForCellHeigeht:)]){
        [_delegate  FHfloatForCellHeigeht:_lableContents.frame.size.height+_lableTime.bottom+CLandR+CTandB ];
    }


}
-(void)setModelPL:(MLZPLModl *)modelPL{
    _lableName.text  = modelPL.userName;
    _lableTime.text = modelPL.updatedAt;
    _labletype.text = @"楼主";
    _lableContents.text= modelPL.contents;
    [_lableContents sizeToFit];




}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
